package com.zj.dmsproxy.wrapper.condition;

import com.zj.dmsproxy.enums.QueryEnum;
import lombok.EqualsAndHashCode;
import lombok.Getter;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;

/**
 * @author 19242
 */
@EqualsAndHashCode(callSuper = true)
@Getter
public class InCondition extends AbstractCondition {

    private final Collection<?> values;

    public InCondition(boolean invert, String field, Collection<?> values) {
        super(invert, field);
        this.values = values;
    }

    @Override
    public Map<String, Object> toCondition() {
        return isInvert() ?
                Collections.singletonMap(getField(), Collections.singletonMap(QueryEnum.NIN.getRelation(), getValues()))
                : Collections.singletonMap(getField(), Collections.singletonMap(QueryEnum.IN.getRelation(), getValues()));
    }
}
